package com.zhuozhou.jdyc.welcome;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.DrawableRes;

import com.zhuozhou.jdyc.R;
import com.zhuozhou.jdyc.api.AppSettingHelper;
import com.zhuozhou.jdyc.base.BaseActivity;
import com.zhuozhou.jdyc.base.BaseViewModel;
import com.zhuozhou.jdyc.databinding.WelcomeLayoutBinding;
import com.zhuozhou.jdyc.wight.customlayout.BannerViewPager;

import static com.zhuozhou.jdyc.api.ConstantsHelper.WELCOME_ACTIVITY_REQUEST_CODE;

/**
 * Created by 方舟 on 2016/10/5.
 * <p>应用第一次安装显示的页面，会有立即体验的提示，后来就没有了
 */
public class WelcomeActivity extends BaseActivity<BaseViewModel, WelcomeLayoutBinding> implements BannerViewPager.OnImageItemClickListener {
    private
    @DrawableRes
    int[] imgs = new int[]{R.mipmap.gesture_background};

    @Override
    public String setTitleBar() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.welcome_layout;
    }

    @Override
    protected boolean hasToolBar() {
        return false;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData(Bundle bundle) {
        binding.customViewPager.init(imgs, this);
        if (imgs.length == 1) {
            binding.runAppRightNow.setVisibility(View.VISIBLE);
        } else {
            binding.customViewPager.getViewPager().setOnImageItemClickListener(this);
        }
        AppSettingHelper.setNotFirstRun();
    }

    public static void show(Activity context) {
        Intent intent = new Intent(context, WelcomeActivity.class);
        context.startActivityForResult(intent, WELCOME_ACTIVITY_REQUEST_CODE);
    }

    public void onClick(View view) {
        setResult(RESULT_OK);
        finish();
    }

    @Override
    public void onItemClick(int itemPosition) {

    }

    @Override
    public void getPosition(int itemPosition) {
        if (itemPosition == imgs.length - 1) {
            binding.runAppRightNow.setVisibility(View.VISIBLE);
        } else {
            binding.runAppRightNow.setVisibility(View.GONE);
        }
    }
}

